package com.burstly.lib.ui;

import com.burstly.lib.component.ComponentFactory;
import com.burstly.lib.component.ComponentQueueElement;
import com.burstly.lib.component.IInternalBurstlyAdListener;
import com.burstly.lib.network.beans.RequestData;
import com.burstly.lib.network.beans.ResponseBean;
import com.burstly.lib.network.beans.cookie.CookieManager;
import com.burstly.lib.network.request.DefaultRequestCallback;
import com.burstly.lib.util.LoggerExt;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Map;

public final class AdRequestCallback extends DefaultRequestCallback<ResponseBean>
{
  private final Reference<BurstlyView> mBurstlyView;
  private final Map<String, String> mClientTargetParams;
  private final boolean mPrecacheRequest;
  private Collection<ComponentQueueElement> mQueueElements;
  private final RequestData mRequestData;

  AdRequestCallback(BurstlyView paramBurstlyView)
  {
    this.mBurstlyView = new WeakReference(paramBurstlyView);
    this.mPrecacheRequest = paramBurstlyView.isPrecacheRequest();
    this.mRequestData = paramBurstlyView.getRequestData();
    this.mClientTargetParams = paramBurstlyView.getClientTargetParams();
  }

  private static void logGarbageCollected()
  {
    BurstlyView.sLog.logError("AdRequestCallback", "Burstly view instance has been garbage collected. Skip response processing.", new Object[0]);
  }

  public Collection<ComponentQueueElement> getQueueElements()
  {
    return this.mQueueElements;
  }

  public void onFailUi(ResponseBean paramResponseBean)
  {
    BurstlyView localBurstlyView = (BurstlyView)this.mBurstlyView.get();
    if (localBurstlyView == null)
    {
      logGarbageCollected();
      return;
    }
    BurstlyView.sLog.logError(localBurstlyView.getBurstlyViewId(), "Malformed server response!", new Object[0]);
    localBurstlyView.startDelayedRequest();
  }

  public void onNoConnection()
  {
    BurstlyView localBurstlyView = (BurstlyView)this.mBurstlyView.get();
    if (localBurstlyView == null)
    {
      logGarbageCollected();
      return;
    }
    localBurstlyView.mInnerWrapper.failedToDisplayAds();
  }

  public void onSuccessInBackground(ResponseBean paramResponseBean)
  {
    BurstlyView localBurstlyView = (BurstlyView)this.mBurstlyView.get();
    if (localBurstlyView == null)
    {
      logGarbageCollected();
      return;
    }
    this.mQueueElements = ComponentFactory.getComponents(localBurstlyView.getContext(), localBurstlyView.getBurstlyViewId(), paramResponseBean, this.mRequestData);
    CookieManager.saveCookies(paramResponseBean.getCookie());
  }

  public void onSuccessUi(ResponseBean paramResponseBean)
  {
    BurstlyView localBurstlyView = (BurstlyView)this.mBurstlyView.get();
    if (localBurstlyView == null)
    {
      logGarbageCollected();
      return;
    }
    localBurstlyView.setPrecacheRequest(this.mPrecacheRequest);
    localBurstlyView.startMainQueue(this.mQueueElements, this.mRequestData, this.mClientTargetParams, true);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.ui.AdRequestCallback
 * JD-Core Version:    0.6.2
 */